package com.zhang.passer.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhang.passer.domain.MapDo;
import com.zhang.passer.mapper.MapMapper;
import com.zhang.passer.service.MapService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("map")
public class MapServiceImpl implements MapService {

    @Autowired
    private MapMapper mapMapper;

    @Override
    public List<MapDo> queryAll(MapDo mapDo) {
        QueryWrapper<MapDo> MapDoQueryWrapper = new QueryWrapper<>(mapDo);
        return mapMapper.selectList(MapDoQueryWrapper);
    }


    @Override
    public Page<MapDo> selectPage(int currentPage, int pageSize, QueryWrapper<MapDo> queryWrapper) {
        //封装pageBean(Mybatis_plus中简单的分页模型)
        Page<MapDo> page = new Page<>(currentPage,pageSize,true);
        //selectPage直接将结果返回给Page对象
        mapMapper.selectPage(page, queryWrapper);
        return page;
    }

    @Override
    public MapDo queryOne(MapDo mapDo) {
        return mapMapper.selectOne(new QueryWrapper<>(mapDo));
    }


}
